<?php
session_start();
require_once 'config.php';

$params = $application['bdd'];
$dsn = $params['type'].':host='.$params['serveur'].';dbname='.$params['instance'];
$user = $params['user'];
$pwd = $params['pwd'];
$options = null;
$pdo = new PDO($dsn, $user, $pwd, $options);
$actif = 0;
if (isset($_GET['activer']) === true && $_GET['activer'] === 'true') {
    $actif = 1;
}

$sql = 'UPDATE garage SET actif=:actif WHERE tank_id=:tankid AND account_id=:account_id';
$bind = array(':tankid' => $_GET['tankid'],
              ':account_id' => $_SESSION['account_id'],
              ':actif' => $actif);
        
$resultat = $pdo->prepare($sql, array(PDO::ATTR_CURSOR => PDO::CURSOR_FWDONLY));
$execution = $resultat->execute($bind);

$retour = $_GET['tankid'];
if ($execution === false) {
    $retour = 'ko';
}

header('Content-Type: text/xml'); 
echo "<?xml version=\"1.0\"?>\n";
echo "<reserve>\n";
 
echo '<donnee>'.$retour.'</donnee>';

echo "</reserve>\n";
 
?>